#include<bits/stdc++.h>
namespace IO{
	inline char gc(){
	static const int Rlen=1<<20|1;static char buf[Rlen],*p1,*p2;
	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,Rlen,stdin),p1==p2)?EOF:*p1++;
	}
	template<typename T>T get_integer(){
		char c;bool f=false;while(!isdigit(c=gc()))f=c=='-';T x=c^48;
		while(isdigit(c=gc()))x=((x+(x<<2))<<1)+(c^48);return f?-x:x;
	}
	inline int gi(){return get_integer<int>();}
	char obuf[(int)(4e6+7)],*oh=obuf;
	inline void prt(char c){*oh++=c;}
	inline void prt(const char *s){
		while(*s)*oh++=*s++;
	}
	template<typename T>void prt(T a){
		static char ch[23];int tl=0;
		if(a<0)*oh++='-',a=-a;
		do ch[++tl]=a%10;while(a/=10);
		while(tl)*oh++=ch[tl--]^48;
	}
	template<typename T,class ...Args>
	void prt(T a,Args...args){
		prt(a),prt(args...);
	}
	struct obuf_flusher{
		~obuf_flusher(){fwrite(obuf,1,oh-obuf,stdout);}
	}Flusher;
}
using namespace std;
using namespace IO;
const int N=1000010;
int maxl[N<<2],minr[N<<2],p[N<<2];
multiset<int>pl,pr,dl[N],dr[N];
void updatel(int x,int y,int l,int r,int rt){
	int mid=(l+r)>>1;
	if(l==r){
		minr[rt]=(dl[l].empty()?1e9:*dl[l].begin());
		return;
	}
	x<=mid?updatel(x,y,l,mid,rt<<1):updatel(x,y,mid+1,r,rt<<1|1);
	minr[rt]=min(minr[rt<<1],minr[rt<<1|1]);
	p[rt]=min({p[rt<<1],p[rt<<1|1],minr[rt<<1|1]-maxl[rt<<1]});
}
void updater(int x,int y,int l,int r,int rt){
	int mid=(l+r)>>1;
	if(l==r){
		maxl[rt]=(dr[l].empty()?-1e9:*dr[l].rbegin());
		return;
	}
	x<=mid?updater(x,y,l,mid,rt<<1):updater(x,y,mid+1,r,rt<<1|1);
	maxl[rt]=max(maxl[rt<<1],maxl[rt<<1|1]);
	p[rt]=min({p[rt<<1],p[rt<<1|1],minr[rt<<1|1]-maxl[rt<<1]});
}
int main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	int n=1e6,m=gi(),x,y;
	char c;
	for(int i=1;i<=n*4;i++){
		minr[i]=p[i]=1e9;
		maxl[i]=-1e9;
	}
	for(int i=1;i<=m;i++){
		c=0;
		while(!isalpha(c)){
			c=gc();
		}
		x=gi();
		y=gi()-1;
		if(c=='A'){
			dl[x].insert(y);
			dr[y].insert(x);
			updatel(x,y,1,n,1);
			updater(y,x,1,n,1);
			pl.insert(x);
			pr.insert(y);
		}
		else{
			dl[x].erase(dl[x].find(y));
			dr[y].erase(dr[y].find(x));
			updatel(x,y,1,n,1);
			updater(y,x,1,n,1);
			pl.erase(pl.find(x));
			pr.erase(pr.find(y));
		}
		if(*pl.rbegin()<=*pr.begin()){
			prt((*dl[*pl.rbegin()].begin()-*dr[*pr.begin()].rbegin()+1),"\n");
		}
		else{
			prt(p[1]+1,"\n");
		}
	}
}